package com.example.wan_android.ui.activity

import androidx.recyclerview.widget.GridLayoutManager
import com.example.wan_android.BR
import com.example.wan_android.R
import com.example.wan_android.adapter.FriendWebAdapter
import com.example.wan_android.databinding.ActivityFriendWebBinding
import com.example.wan_android.tools.SpacesItemDecoration
import com.example.wan_android.viewmodel.FriendWebViewModel

class FriendWebActivity : BaseActivity<ActivityFriendWebBinding, FriendWebViewModel>(
    FriendWebViewModel::class.java,
    R.layout.activity_friend_web,
    BR.viewModel
) {
    val adapter by lazy {
        FriendWebAdapter(mViewModel!!)
    }

    override fun initView() {
        mViewModel?.friendLiveData?.observe(this) {
            it.onSuccess {
                adapter.setListData(it)
            }
        }
        mViewDataBinding?.rvFriendWeb?.adapter = adapter
        mViewDataBinding?.rvFriendWeb?.addItemDecoration(SpacesItemDecoration(20))
        mViewDataBinding?.rvFriendWeb?.layoutManager = GridLayoutManager(this, 4)
    }
}